package com.qingpeng.pay.fragment;

import com.qingpeng.pay.R;
import com.qingpeng.pay.adapter.MessageAdapter;
import com.qingpeng.pay.adapter.MoneyRecordAdapter;
import com.qingpeng.pay.api.Host;
import com.qingpeng.pay.api.RedBag;
import com.qingpeng.pay.base.BaseFragment;
import com.qingpeng.pay.beans.MessageBean;
import com.qingpeng.pay.beans.WithdrawBean;
import com.qingpeng.pay.okhttp.RetrofitCreateHelper;
import com.qingpeng.pay.utils.ToastUtils;

import java.util.List;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class WholeFragment extends BaseFragment {
    private List<WithdrawBean.DataProductBean> mData;
    @Override
    protected int getLayoutId() {
        return R.layout.fragment_notice_list;
    }

    @Override
    protected int getRefreshId() {
        return 0;
    }

    @Override
    protected int getListViewId() {
        return R.id.recycler;
    }

    @Override
    public void onResume() {
        super.onResume();
        Call<WithdrawBean> zfnotion = RetrofitCreateHelper.createApi(RedBag.class, Host.HOST).acountlist("0");
        zfnotion.enqueue(new Callback<WithdrawBean>() {

            @Override
            public void onResponse(Call<WithdrawBean> call, Response<WithdrawBean> response) {
                WithdrawBean body = response.body();
                if (body.getStatus()!=1){
                    ToastUtils.showToast(mContext,body.getInfo());
                    return;
                }
                mData = body.getData();
                initAdapter();
            }

            @Override
            public void onFailure(Call<WithdrawBean> call, Throwable t) {
                ToastUtils.showToast(mContext, "网络请求错误,请稍后重试");
            }
        });
    }

    @Override
    protected void initAdapter() {
        mAdapter=new MoneyRecordAdapter(R.layout.item_money_list);
        mAdapter.setNewData(mData);
        super.initAdapter();
    }
}
